package com.guli.edu.controller;

import com.guli.edu.entity.Course;
import com.guli.edu.entity.EduTeacher;
import com.guli.edu.service.CourseService;
import com.guli.edu.service.EduTeacherService;
import com.guli.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ZHAOZHENYU
 * @since 2022/10/1
 */

//@CrossOrigin
@RequestMapping("/edu/index")
@RestController
public class IndexController {

    @Autowired
    private EduTeacherService eduTeacherService;

    @Autowired
    private CourseService courseService;

    //查询前8条热门课程，查询前4条名师
    @GetMapping("/getTeacherAndCourse")
    public R index(){

        List<Course> courseList = courseService.getHotCourse();
        List<EduTeacher> teacherList = eduTeacherService.getHotTeacher();

        return R.ok().data("courseList", courseList).data("teacherList", teacherList);

    }


}
